{extend name="index/index"}
{block name="content"}

<div class="tpl-content-wrapper">
    <div class="tpl-content-page-title">
        Amaze UI 文字列表
    </div>
    <ol class="am-breadcrumb">
        <li><a href="#" class="am-icon-home">首页</a></li>
        <li><a href="#">Amaze UI CSS</a></li>
        <li class="am-active">文字列表</li>
    </ol>
    <div class="tpl-portlet-components">
        <div class="portlet-title">
            <div class="caption font-green bold">
                <span class="am-icon-code"></span> 列表
            </div>
            <div class="tpl-portlet-input tpl-fz-ml">
                <div class="portlet-input input-small input-inline">
                    <div class="input-icon right">
                        <i class="am-icon-search"></i>
                        <input type="text" class="form-control form-control-solid" placeholder="搜索..."></div>
                </div>
            </div>


        </div>
        <div class="tpl-block">
            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-6">
                    <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            <button type="button" class="am-btn am-btn-default am-btn-success"
                                    data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0, width: 400, height: 225}">
                                <span class="am-icon-plus"></span> 新增
                            </button>
                            <button type="button" class="am-btn am-btn-default am-btn-secondary"><span
                                    class="am-icon-save"></span> 保存
                            </button>
                            <button type="button" class="am-btn am-btn-default am-btn-warning"><span
                                    class="am-icon-archive"></span> 审核
                            </button>
                            <!--<button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>-->
                        </div>
                    </div>
                </div>
                <div class="am-u-sm-12 am-u-md-3">
                    <div class="am-form-group">
                        <select data-am-selected="{btnSize: 'sm'}">
                            <option value="option1">所有类别</option>
                            <option value="option2">IT业界</option>
                            <option value="option3">数码产品</option>
                            <option value="option3">笔记本电脑</option>
                            <option value="option3">平板电脑</option>
                            <option value="option3">只能手机</option>
                            <option value="option3">超极本</option>
                        </select>
                    </div>
                </div>
                <div class="am-u-sm-12 am-u-md-3">
                    <div class="am-input-group am-input-group-sm">
                        <input type="text" class="am-form-field">
                        <span class="am-input-group-btn">
            <button class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search"
                    type="button"></button>
          </span>
                    </div>
                </div>
            </div>
            <div class="am-g">
                <div class="tpl-table-images">
                    {volist name="list" id="v"}
                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-4 del">
                        <div class="tpl-table-images-content">
                            <div class="tpl-i-title">

                            </div>
                            <a href="javascript:;" class="tpl-table-images-content-i">
                                <span class="tpl-table-images-content-i-shadow"></span>
                                <img src="/uploads/{$v['icon']}">
                            </a>

                            <div class="tpl-table-images-content-block">


                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs tpl-edit-content-btn">

                                        <button class="am-btn am-btn-default am-btn-xs am-text-secondary"><span
                                                class="am-icon-pencil-square-o"></span> <a
                                                href="{:url('admin/Serve/edit', ['id'=>$v['id']])}">编辑</a></button>
                                        <button type="button" class="am-btn am-btn-default am-btn-warning"
                                                data-am-modal="{target: '#doc-modal-2', closeViaDimmer: 0, width: 400, height: 225}"><span
                                                class="am-icon-archive"></span> 封面
                                        </button>
                                        <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only del-btn"
                                                data-id="{$v['id']}"><span class="am-icon-trash-o "></span> 删除
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    {/volist}
                    <div class="am-u-lg-12">
                        <div class="am-cf">

                            <div class="am-fr">
                                <ul class="am-pagination tpl-pagination">
                                    <li class="am-disabled"><a href="#">«</a></li>
                                    <li class="am-active"><a href="#">1</a></li>
                                    <li><a href="#">2</a></li>
                                    <li><a href="#">3</a></li>
                                    <li><a href="#">4</a></li>
                                    <li><a href="#">5</a></li>
                                    <li><a href="#">»</a></li>
                                </ul>
                            </div>
                        </div>
                        <hr>
                    </div>

                </div>

            </div>
        </div>
        <div class="tpl-alert"></div>
    </div>


</div>

</div>


<div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">新增一个图片
            <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
        </div>
        <div class="am-modal-bd">
            <form action="{:url('admin/Serve/save')}" method="post" enctype="multipart/form-data">
                <input type="file" name="icon">
                会员卡:
                <select name="cid" id="">
                    {volist name="data" id="d"}
                    <option value="{$d['id']}">{$d['name']}</option>
                    {/volist}
                </select>
                <input type="submit" value="添加" class="am-btn am-btn-default am-btn-success">
            </form>
        </div>
    </div>
</div>



<script src="/assets/js/jquery.min.js"></script>

{js href="/static/toastr.min.js"}
<script>
    // // 设置弹框参数
    // toastr.options = {
    //     closeButton: true,// 是否显示关闭按钮
    //     progressBar: true,// 实现显示计时条
    //     timeOut: "3000",  // 自动关闭时间
    //     positionClass: "toast-bottom-left" // 提示位置
    //     // toast-top-full-width 顶端，宽度铺满整个屏幕
    //     // toast-top-right  顶端右边
    // };


    // 删除动作
    $('.del-btn').click(function () {
        var ac_id = $(this).attr('data-id');
        // console.log('删除ID: '+ ac_id);

        if (confirm('您确定要 [ 删除 ]吗?')) {
            var obj = $(this).parents('.del');
            // console.log(obj);
            // 处理删除

            // toastr.success('123424324');
            delAjax(ac_id, obj);
        }
    });


    function delAjax(id, obj) {
        $.ajax({
            type: 'delete',
            url: '/serve/' + id,
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if (data.status) {
                    toastr.success('123424324');
                    obj.remove();
                } else {
                    toastr.error(data.info, 'FBI WARING:');
                }
            },
            error: function () {
                alert('AJAX操作失败!');
            }
        });
    }
</script>
</body>

</html>
{/block}